/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FercharOcorrencia.java
 *
 * Created on 12/08/2009, 13:39:21
 */
package br.com.sismovimentacao.view;

import br.com.sismovimentacao.bean.Movimentacao;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.JOptionPane;

/**
 *
 * @author lac
 */
public class FecharOcorrenciaView extends javax.swing.JDialog {

    private int numClik = 0;

    /** Creates new form FercharOcorrencia */
    public FecharOcorrenciaView(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        jPanel2 = new javax.swing.JPanel();
        confirma = new javax.swing.JButton();
        cancela = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        viaturaField = new javax.swing.JTextField();
        motoristaField = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        destinoField = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        horaInicioField = new javax.swing.JFormattedTextField();
        dataInicioField = new javax.swing.JFormattedTextField();
        dataFinalField = new javax.swing.JFormattedTextField();
        jPanel3 = new javax.swing.JPanel();
        hodometroFinalField = new javax.swing.JTextField();
        horaFinalField = new javax.swing.JFormattedTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Fechando Ocorrência");
        setAlwaysOnTop(true);
        setResizable(false);

        confirma.setFont(new java.awt.Font("Tahoma", 1, 18));
        confirma.setText("Confirmar");
        confirma.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                confirmaActionPerformed(evt);
            }
        });
        confirma.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                confirmaKeyPressed(evt);
            }
        });

        cancela.setFont(new java.awt.Font("Tahoma", 1, 18));
        cancela.setText("Cancelar");
        cancela.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelaActionPerformed(evt);
                carcelarMovimentacao(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 288, Short.MAX_VALUE)
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(confirma)
                    .addGap(32, 32, 32)
                    .addComponent(cancela)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 48, Short.MAX_VALUE)
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup()
                    .addGap(6, 6, 6)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(confirma)
                        .addComponent(cancela))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );

        jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jLabel3.setFont(new java.awt.Font("Tahoma", 3, 24));
        jLabel3.setForeground(new java.awt.Color(255, 51, 0));
        jLabel3.setText("<html><center>Fechamento de Ocorrência");

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel4.setText("Motorista:");

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel5.setText("Viatura:");

        viaturaField.setEditable(false);
        viaturaField.setFont(new java.awt.Font("Tahoma", 0, 14));
        viaturaField.setEnabled(false);

        org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${registroAtual.vtncodg.vtcmodl}"), viaturaField, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        motoristaField.setEditable(false);
        motoristaField.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        motoristaField.setEnabled(false);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ, this, org.jdesktop.beansbinding.ELProperty.create("${registroAtual.psncodg.pscdesc}"), motoristaField, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel6.setText("Destino:");

        destinoField.setEditable(false);
        destinoField.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        destinoField.setAutoscrolls(false);
        destinoField.setEnabled(false);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${registroAtual.dtncodg.dtcdesc}"), destinoField, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel7.setText("Horário Saída:");

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel8.setText("Data Saída:");

        jLabel9.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel9.setText("Data Chegada:");

        horaInicioField.setEditable(false);
        horaInicioField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(java.text.DateFormat.getTimeInstance(java.text.DateFormat.SHORT))));
        horaInicioField.setEnabled(false);
        horaInicioField.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${registroAtual.mvtinic}"), horaInicioField, org.jdesktop.beansbinding.BeanProperty.create("value"));
        bindingGroup.addBinding(binding);

        dataInicioField.setEditable(false);
        dataInicioField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter()));
        dataInicioField.setEnabled(false);
        dataInicioField.setFont(new java.awt.Font("Tahoma", 0, 14));

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${registroAtual.mvddinic}"), dataInicioField, org.jdesktop.beansbinding.BeanProperty.create("value"));
        bindingGroup.addBinding(binding);

        dataFinalField.setEditable(false);
        dataFinalField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter()));
        dataFinalField.setEnabled(false);
        dataFinalField.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${registroAtual.mvddfinl}"), dataFinalField, org.jdesktop.beansbinding.BeanProperty.create("value"));
        bindingGroup.addBinding(binding);

        jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        hodometroFinalField.setFont(new java.awt.Font("Tahoma", 0, 18));

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${registroAtual.vtncodg.vtnodom}"), hodometroFinalField, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        hodometroFinalField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                hodometroFinalFieldKeyPressed(evt);
            }
        });

        horaFinalField.setColumns(5);
        horaFinalField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(java.text.DateFormat.getTimeInstance(java.text.DateFormat.SHORT))));
        horaFinalField.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        horaFinalField.setSelectionEnd(5);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${registroAtual.mvtfinl}"), horaFinalField, org.jdesktop.beansbinding.BeanProperty.create("value"));
        bindingGroup.addBinding(binding);

        horaFinalField.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                horaFinalFieldMouseClicked(evt);
            }
        });
        horaFinalField.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                horaFinalFieldFocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                horaFinalFieldFocusLost(evt);
            }
        });
        horaFinalField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                horaFinalFieldKeyPressed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18));
        jLabel1.setText("Hora de Chegada:");

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 18));
        jLabel2.setText("Hodômetro de Chegada:");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(55, 55, 55)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(hodometroFinalField)
                    .addComponent(horaFinalField, javax.swing.GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE))
                .addContainerGap(116, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(horaFinalField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(hodometroFinalField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addContainerGap(31, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 327, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(95, 95, 95))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jLabel4)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(motoristaField, javax.swing.GroupLayout.PREFERRED_SIZE, 175, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jLabel6)
                                        .addGap(18, 18, 18)
                                        .addComponent(destinoField, javax.swing.GroupLayout.PREFERRED_SIZE, 175, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jLabel5)
                                        .addGap(18, 18, 18)
                                        .addComponent(viaturaField, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGap(18, 18, 18)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel8)
                                    .addComponent(jLabel7)
                                    .addComponent(jLabel9))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(dataInicioField, javax.swing.GroupLayout.DEFAULT_SIZE, 177, Short.MAX_VALUE)
                                    .addComponent(horaInicioField)
                                    .addComponent(dataFinalField))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                        .addGap(21, 21, 21))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel3)
                .addGap(25, 25, 25)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(motoristaField, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8)
                    .addComponent(dataInicioField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(11, 11, 11)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(destinoField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6)
                    .addComponent(jLabel7)
                    .addComponent(horaInicioField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(viaturaField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9)
                    .addComponent(dataFinalField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(19, 19, 19)
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(175, 175, 175)
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(20, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(5, 5, 5))
        );

        bindingGroup.bind();

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void cancelaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelaActionPerformed
        this.setVisible(false);
        carcelarMovimentacao(evt);
    }//GEN-LAST:event_cancelaActionPerformed

    private void confirmaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_confirmaActionPerformed
        try {
            if (horaFinalField.getText().length() == 0 || hodometroFinalField.getText().length() == 0) {
                JOptionPane.showMessageDialog(rootPane, "Informe Hora e Hodômetro!");
                horaFinalField.grabFocus();
            } else {
                if (registroAtual.getMvnoini() >= Integer.parseInt(hodometroFinalField.getText())) {
                    JOptionPane.showMessageDialog(rootPane, "O Hodômetro de chegada de ser maior que o Hodômetro de saida");
                    hodometroFinalField.grabFocus();
                } else {
                    int opc = JOptionPane.showConfirmDialog(rootPane, "Tem certeza que deseja encerrar a ocorrência?", "Comfirmação", 2);
                    if (opc == 0) {
                        MovTst.m.setMvnofin(hodometroFinalField.getText());
                        MovTst.m.setMvddfinl();
                        setConfirmaMovimentacao(true);
                        dispose();
                    } else if (opc == 2) {
                        setConfirmaMovimentacao(false);
                    }
                }
            }
        } catch (Exception e) {
        }
    }//GEN-LAST:event_confirmaActionPerformed

    private void carcelarMovimentacao(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_carcelarMovimentacao
        setConfirmaMovimentacao(false);
        setVisible(false);
    }//GEN-LAST:event_carcelarMovimentacao

    private void horaFinalFieldFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_horaFinalFieldFocusGained
        horaFinalField.setSelectionStart(0);
        horaFinalField.setSelectionEnd(5);
    }//GEN-LAST:event_horaFinalFieldFocusGained

    private void horaFinalFieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_horaFinalFieldKeyPressed
        try {
            if (evt.getKeyChar() == '\n') {
                hodometroFinalField.grabFocus();
            } else {
                switch (evt.getKeyChar()) {
                    case '\b': /*str.append(getKeyText(VK_BACK_SPACE));*/
                        this.numClik = 0;
                        break;
                    case '\t': /*str.append(getKeyText(VK_TAB));*/
                        this.numClik = 0;
                        break;
                    case '\n': /*str.append(getKeyText(VK_ENTER));*/
                        this.numClik = 0;
                        break;
                    case '\u0018': /*str.append(getKeyText(VK_CANCEL));*/
                        this.numClik = 0;
                        break;
                    case '\u001b': /*str.append(getKeyText(VK_ESCAPE));*/
                        this.numClik = 0;
                        break;
                    case '\u007f': /*str.append(getKeyText(VK_DELETE));*/
                        this.numClik = 0;
                        break;
                    default:
                        numClik++;
                        String valor = horaFinalField.getText();
                        if (this.numClik == 3) {
                            horaFinalField.setText(valor + ":");
                        }
                        if (valor.length() == 4) {
                            hodometroFinalField.grabFocus();
                        }
                }
            }

        } catch (Exception e) {
        }
    }//GEN-LAST:event_horaFinalFieldKeyPressed

    private void horaFinalFieldMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_horaFinalFieldMouseClicked
        horaFinalField.setSelectionStart(0);
        horaFinalField.setSelectionEnd(5);
    }//GEN-LAST:event_horaFinalFieldMouseClicked

    private void horaFinalFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_horaFinalFieldFocusLost
        this.numClik = 0;
    }//GEN-LAST:event_horaFinalFieldFocusLost

    private void hodometroFinalFieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_hodometroFinalFieldKeyPressed
        if (evt.getKeyChar() == '\n') {
            confirmaActionPerformed(null);
        }
    }//GEN-LAST:event_hodometroFinalFieldKeyPressed

    private void confirmaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_confirmaKeyPressed
        if (evt.getKeyChar() == '\n') {
            confirmaActionPerformed(null);
        }
    }//GEN-LAST:event_confirmaKeyPressed

    public void carregarCampos(java.awt.event.ActionEvent evt) {
        SimpleDateFormat formataData = new SimpleDateFormat("dd/MM/yyyy");
        this.dataFinalField.setText(formataData.format(new Date()));
        hodometroFinalField.setText("");
        SimpleDateFormat formataHora = new SimpleDateFormat("HH:mm");
        this.horaFinalField.setText(formataHora.format(new Date()));
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                FecharOcorrenciaView dialog = new FecharOcorrenciaView(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    //
    //PROPRIEDADE QUE SELECIONA O REGISTRO ATUAL DE MOVIMENTAÇÃO
    //
    protected Movimentacao registroAtual;

    /**
     * Get the value of registroAtual
     *
     * @return the value of registroAtual
     */
    public Movimentacao getRegistroAtual() {
        return registroAtual;
    }

    /**
     * Set the value of registroAtual
     *
     * @param registroAtual new value of registroAtual
     */
    public void setRegistroAtual(Movimentacao registroAtual) {
        Movimentacao oldRecord = this.registroAtual;
        this.registroAtual = registroAtual;
        propertyChangeSupport.firePropertyChange("registroAtual", oldRecord, registroAtual);

    }
    private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);

    /**
     * Add PropertyChangeListener.
     *
     * @param listener
     */
    public void addPropertyChangeListener(PropertyChangeListener listener) {
        propertyChangeSupport.addPropertyChangeListener(listener);
    }

    /**
     * Remove PropertyChangeListener.
     *
     * @param listener
     */
    public void removePropertyChangeListener(PropertyChangeListener listener) {
        propertyChangeSupport.removePropertyChangeListener(listener);
    }
    //FIM DA PROPRIEDADE QUE SELEC....
    protected boolean confirmaMovimentacao;

    /**
     * Get the value of comfirmaMovimentacao
     *
     * @return the value of comfirmaMovimentacao
     */
    public boolean isConfirmaMovimentacao() {
        return confirmaMovimentacao;
    }

    /**
     * Set the value of comfirmaMovimentacao
     *
     * @param comfirmaMovimentacao new value of comfirmaMovimentacao
     */
    public void setConfirmaMovimentacao(boolean comfirmaMovimentacao) {
        this.confirmaMovimentacao = comfirmaMovimentacao;
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton cancela;
    private javax.swing.JButton confirma;
    private javax.swing.JFormattedTextField dataFinalField;
    private javax.swing.JFormattedTextField dataInicioField;
    private javax.swing.JTextField destinoField;
    private javax.swing.JTextField hodometroFinalField;
    private javax.swing.JFormattedTextField horaFinalField;
    private javax.swing.JFormattedTextField horaInicioField;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JTextField motoristaField;
    private javax.swing.JTextField viaturaField;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables
}
